//
//  HLRechargeContentView.m
//  YueYue
//
//  Created by LiuYu on 2024/11/5.
//

#import "HLRechargeContentView.h"
#import "HLRechargeAttachment.h"
#import "HLIMKitMessageModel.h"

@implementation HLRechargeContentView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.bubbleImageView.image = [UIImage imageNamed:@"im_recharge_bg"];
    
    UIImageView *icon = [UIImageView.alloc init];
    icon.image = [UIImage imageNamed:@"im_recharge_icon"];
    [self addSubview:icon];
    [icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(11);
        make.width.height.mas_equalTo(24);
    }];
    
    UILabel *label = [UILabel.alloc init];
    label.text = @"余额不足";
    label.textColor = [UIColor qmui_colorWithHexString:@"#252329"];
    label.font = UIFontMediumMake(16);
    [self addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(icon.mas_right).offset(6);
        make.centerY.equalTo(icon);
    }];
    
    _contentLabel = [UILabel.alloc init];
    _contentLabel.textColor = [UIColor qmui_colorWithHexString:@"#A2A6B0"];
    _contentLabel.font = UIFontMake(12);
    _contentLabel.text = @"当前余额不足，赶快充值吧";
    [self addSubview:_contentLabel];
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(14);
        make.bottom.mas_equalTo(-12);
        make.right.mas_lessThanOrEqualTo(-83);
    }];
    
    QMUIButton *rechargeLabel = [QMUIButton buttonWithType:UIButtonTypeCustom];
    [rechargeLabel setTitle:@"立即充值" forState:UIControlStateNormal];
    [rechargeLabel setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    rechargeLabel.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
    rechargeLabel.backgroundColor = [UIColor qmui_colorWithHexString:@"#FF526C"];
    rechargeLabel.layer.cornerRadius = 14.5;
    rechargeLabel.layer.masksToBounds = YES;
    rechargeLabel.contentEdgeInsets = UIEdgeInsetsMake(6, 0, 6, 0);
    [rechargeLabel addTarget:self action:@selector(recharge) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:rechargeLabel];
    [rechargeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(65);
        make.height.mas_greaterThanOrEqualTo(29);
        make.centerY.equalTo(self);
        make.right.mas_equalTo(-16);
    }];
}

- (void)refreshData:(HLIMKitMessageModel *)messageModel
{
    [super refreshData:messageModel];
    
    self.bubbleImageView.image = [UIImage imageNamed:@"im_recharge_bg"];
}

- (void)recharge
{
    [HLUIHelper h5WithURL:HLH5IncomeUrl controller:[QMUIHelper visibleViewController]];
}

@end
